using FlowCanvas.Nodes;
using Yoozoo.Gameplay.Liberty.StreetEvent;

namespace Yoozoo.Gameplay.Liberty.Nodes
{
    public class StreetPlayerTransmission: CallableActionNode
    {
        public bool IsRandom = true;
        
        public override void Invoke()
        {
            var streetEvent = StreetFightEvent.Instance;
            if (streetEvent != null)
            {
                if (IsRandom)
                {
                    var index = UnityEngine.Random.Range(0, streetEvent.BornPointList.Length);
                    var point = streetEvent.BornPointList[index];
                    if (point!=null)
                    {
                        BlueprintUtils.PlayerTransmission(point.position,point.eulerAngles);
                    }
                }
                else
                {
                    var point = streetEvent.BornPointList[0];
                    BlueprintUtils.PlayerTransmission(point.position,point.eulerAngles);
                }
            }
        }
    }
}